﻿using Microsoft.Win32;

namespace PMIS.BLL.System
{
	/// <summary>
	/// 注册表操作
	/// </summary>
	public class BL_Registry
	{
		#region 常量
		/// <summary>
		/// 注册表根键
		/// </summary>
		private const string strRegistrkeyRoot = @"HKEY_LOCAL_MACHINE\SOFTWARE\PMIS";
		#endregion

		#region 单例
		/// <summary>
		/// 本类的实例
		/// </summary>
		private static BL_Registry bl = null;
		/// <summary>
		/// 用于本类实现单例的Locker
		/// </summary>
		private static object locker = new object();
		/// <summary>
		/// 构造函数
		/// </summary>
		private BL_Registry()
		{

		}
		/// <summary>
		/// 获取本类的实例
		/// </summary>
		/// <returns></returns>
		public static BL_Registry GetInstance()
		{
			if (bl == null)
			{
				lock (locker)
				{
					if (bl == null)
						bl = new BL_Registry();
				}
			}

			return bl;
		}
		#endregion

		#region 业务逻辑
		/// <summary>
		/// 获取注册表键值
		/// </summary>
		/// <param name="key">键值</param>
		/// <returns></returns>
		public string GetValue(string key)
		{
			return (string)Registry.GetValue(strRegistrkeyRoot, key, string.Empty);
		}
		/// <summary>
		/// 保存注册表键值
		/// </summary>
		/// <param name="key">键值</param>
		/// <param name="value">路径</param>
		public void SetValue(string key, string value)
		{
			Registry.SetValue(strRegistrkeyRoot, key, value);
		}
		#endregion
	}
}
